package com.sikaryofficial.system.api.factory;

import com.sikaryofficial.common.core.domain.R;
import com.sikaryofficial.system.api.RemoteHiSMKDigDataService;
import com.sikaryofficial.system.api.domain.customer.RegisterChannelBodyBO;
import com.sikaryofficial.system.api.domain.order.OrderHeaderVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;

import java.util.List;

/**
 * @author : wuweihong
 * @desc : 外网调用内网-降级
 * @date : 2024-11-05
 */


@Slf4j
public class HiSMKDigDataFallbackFactory implements FallbackFactory<RemoteHiSMKDigDataService> {
	@Override
	public RemoteHiSMKDigDataService create(Throwable cause) {
		return new RemoteHiSMKDigDataService() {
			@Override
			public R<Boolean> syncOrder(List<OrderHeaderVO> orderHeaderVOs) {
				log.warn("sync order fail: {}", cause.getMessage());
				return R.fail("sync order fail: {}" + cause.getMessage());
			}

			@Override
			public R<Boolean> syncChannelUser(RegisterChannelBodyBO channelBody) {
				log.warn("sync customer fail: {}", cause.getMessage());
				return R.fail("sync customer fail: {}" + cause.getMessage());
			}
		};
	}
}
